package com.cet.spring_batch_study.jobs.reconciliation;

import com.cet.spring_batch_study.jobs.sftp.SftpDownloadTasklet;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

@Configuration
public class ReconJobConfig {

  @Bean
  public Job reconJob(JobRepository repo,
                      Step stepSftpFetch) {
    return new JobBuilder("reconJob", repo)
        .start(stepSftpFetch)
        .build();
  }

  @Bean
  public Step stepSftpFetch(JobRepository repo, PlatformTransactionManager tx,
                            SftpDownloadTasklet t) {
    return new StepBuilder("stepSftpFetch", repo).tasklet(t, tx).build();
  }
}
